- We can do some preliminary statistical analysis through the visualisations =
geom_smooth evaluates the relationship between variables
ggplot(gapminder, aes(x = gdpPercap, y = lifeExp, colour = continent)) +
geom_point(alpha = 0.5, size = 2) +
facet_grid(. ~ continent) +
# geom_smooth allows us to plot the linear relationship between 2 variables
# method determines the modeling method, in this case linear model
# se determines whether we want to plot the standard error
# lwd states the line width
geom_smooth(color = "black", method = "lm", se = TRUE, lwd = 0.5) +
labs(x = "GDP per capita",
y = "Life Expectancy",
title = "Tracking the relationship between GDP per capita and Life Expectancy",
caption = "Source: gapminder dataset")